
    package icani.web.servlet.core;

    import icani.domainmodel.core.*;
    import icani.core.*;
    
    import java.io.*;
    import javax.servlet.http.*;


    public class CrudCreateCane extends HttpServlet {

        public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
        
            this.processRequest(request, response);
        }

        public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        
            this.processRequest(request, response);
        }

        public void processRequest(HttpServletRequest request, HttpServletResponse response) throws IOException {
        
            response.setHeader("Pragma", "No-cache");
            response.setHeader("Cache-Control", "no-cache,no-store,max-age=0");
            response.setDateHeader("Expires", 1);
            response.setContentType("text/plain");
            PrintWriter out = response.getWriter();
            
            
            String nomi = request.getParameter("nomi");
            String cognomi = request.getParameter("cognomi");
            String soprannomi = request.getParameter("soprannomi");
            String genere = request.getParameter("genere");
            String annodinascita = request.getParameter("annodinascita");
            String razzetags = request.getParameter("razzetags");
            String dimensione = request.getParameter("dimensione");
            String eta = request.getParameter("eta");
            String padrini = request.getParameter("padrini");
        
            try {
                    CoreApplication.createCane(nomi,cognomi,soprannomi,genere,annodinascita,razzetags,dimensione,eta,padrini);
                
                    out.println("OK");
            
            } catch (Exception ex) {
            
                        out.println("ERROR: " + ex.getMessage());
            }
            
            out.flush();
            out.close();
        }

    }
    
